<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+ "://"+request.getServerName()+":"+request.getServerPort()+ path+"/";
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=chrome">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        .modal-header {
            text-align: center;
        }

        table td {
            text-align: center;
            border: 0px;
        }

        table{
            table-layout:fixed;
        }

        .colStyle {
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

    </style>
    <title>分类列表</title>
    <!-- 分页 -->
    <link href="<%=basePath%>css/mypage.css" rel="stylesheet">

    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

    <link href="<%=basePath%>css/bootstrap-datetimepicker.min.css" rel="stylesheet">

</head>

<body>
<jsp:include page="../main_top.jsp"></jsp:include>
<jsp:include page="../main_left.jsp"></jsp:include>
<!--=============================================================================================================================================================================-->
<!--main-container-part-->
<!--main-container-part-->
<div id="content" style="margin-right: 1px; margin-top: 40px;">
    <!--breadcrumbs-->
    <div id="content-header">
        <div id="breadcrumb">
            <a href="<%=basePath%>admin/indexs" title="主页" class="tip-bottom"><i
                    class="icon-home"></i>主页</a> <a title="留言列表" class="tip-bottom">留言列表</a>
        </div>
    </div>
    <!--End-breadcrumbs-->

    <!-- Page table -->
    <div class="container" style="width: 1000px;">
        <!-- &lt;!&ndash; Marketing Icons Section &ndash;&gt;-->

        <div class="col-lg-12">
            <h2 class="page-header"style="margin-top: 10px; text-align: center; font-family: '微软雅黑', Verdana, sans-serif, '宋体', serif;"> 留言列表显示</h2>
        </div>

        <!--搜索栏-->
        <%--<form class="form-horizontal" id="myserchform" name="myform"
            action="<%=basePath%>admin/searchNotice" method="post">
            <div class="form-group">
                <div class="col-sm-8" style="text-align: center;">
                    <span>留言编号：</span> <input type="number" placeholder="请输入纯数字~"
                        name="id" value="${searchnotice.id}" /> <span>留言信息：</span> <input
                        type="text" name="context" value="${searchnotice.context}" /> <span>状态：</span>
                    <select name="status" id="myselected">
                        <option value="" selected="selected">请选择留言状态</option>
                        <option value="0">未读</option>
                        <option value="1">已读</option>
                    </select>
                </div>
                <div class="col-sm-4">
                    <button class="btn btn-success btn-sm" type="submit">查找</button>
                    <button class="btn btn-danger btn-sm" type="button"
                        id="deleteNoticeButton">删除</button>
                </div>
            </div>
        </form>--%>

        <!--表格显示-->
        <table class="table table-bordered" style="table-layout:fixed;">
            <thead>
            <tr>
                <th><input type="checkbox" id="selectAllButton"></th>
                <th>ID</th>
                <%--<th>留言用户</th>--%>
                <th>留言内容</th>
                <th>推送时间</th>
                <th>留言状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${noticeGrid.rows}" var="item">
                <tr>
                    <td><input type="checkbox" name="itemIds" value="${item.id}"></td>
                        <%--<td>${notice.user.userid}</td>--%>
                    <td>${item.id}</td>
                    <td>${item.context}</td>
                    <td>${item.createAt}</td>
                    <td>${item.status}
                    <c:if test="${item.status == 0}">
                        <span style="color: blue">未读</span>
                    </c:if> <c:if test="${item.status == 1}">
                        <span style="color: red">已读</span>
                    </c:if> </td>
                    <td>
                        <button type="button" class="btn btn-primary btn-sm"
                                onclick="doView(${item.id})">查看</button>
                        <button type="button" class="btn btn-info btn-sm"
                                onclick="doDelete(${item.id})">删除</button>
                        <%--<button class="btn btn-danger btn-sm" type="button"
                                id="deleteOrdersButton">删除</button>--%>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>

        <!--分页条-->
        <div style="text-align: right">
            <div class="pagination">
                <ul>
                    <li><a>总信息数:${noticeGrid.total }个</a></li>
                    <li><a>第${noticeGrid.current }页</a></li>
                    <c:if test="${noticeGrid.current ne 1 }">
                        <li><a
                            href="<%=basePath%>admin/noticeList?pageNum=${noticeGrid.current-1 }">上一页</a>
                        </li>
                    </c:if>

                    <c:if test="${noticeGrid.current < (noticeGrid.total+4)/5-1 }">
                        <li><a
                            href="<%=basePath%>admin/noticeList?pageNum=${noticeGrid.current+1 }">下一页</a>
                        </li>
                    </c:if>
                </ul>
            </div>
        </div>
    </div>
</div>


        <!--==================================================================================================================-->
        <jsp:include page="../main_bottom.jsp"></jsp:include>
        <%--
            <!--修改  模态框（Modal） -->
            <div class="modal fade" id="editModal" tabindex="-1" role="dialog"
                aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">修改订单信息</h4>
                        </div>
                        <div class="modal-body" style="height: 0 auto;">
                            <form class="form-horizontal" id="myeditform" name="myform">
                                <input type="hidden" id="id" name="id" value="" />
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">订单编号:</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="orderNum" style="margin-top: 8px;" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">订单信息:</label>
                                    <div class="col-sm-8">
                                        <textarea rows="3" cols="20"  name="orderInformation" style="margin-top: 8px; width: 365px">
                                        </textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">订单价格:</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="orderPrice" style="margin-top: 8px;" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">创建时间:</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="orderDate" class="form-control form_datetime" style="margin-top: 8px;">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">状态:</label>
                                    <div class="col-sm-8">
                                        <select name="orderState"
                                            style="margin-top: 8px; width: 372px; height: 27px;">
                                            <option value="1" selected="selected">代发货</option>
                                            <option value="2">待收货</option>
                                            <option value="3">已完成</option>
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>

                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" onclick="doSave()">提交更改</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal -->
            </div>--%>

        <!-- 查看 模态框（Modal） -->
       <div class="modal fade" id="viewModal" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">查看留言信息</h4>
                    </div>
                    <div class="modal-body" style="height: 0 auto ;">
                        <form class="form-horizontal" id="myviewform" name="myform">
                            <input type="hidden" id="id" name="id" value="" />
                            <div class="form-group">
                                <label class="col-sm-4 control-label">ID:</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  name="id"
                                           readonly style="margin-top: 8px;" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">留言内容:</label>
                                <div class="col-sm-8">
								<textarea rows="3" cols="20"  name="context"
                                          readonly style="margin-top: 8px; width: 365px">
								</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">创建时间:</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="createat" readonly style="margin-top: 8px;" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">留言状态</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="status" readonly style="margin-top: 8px;" />
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
</body>

<script type="text/javascript" src="<%=basePath%>js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/bootstrap.min.js"></script>
<!-- datetimepicker -->
<script type="text/javascript"
        src="<%=basePath%>js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
        src='<%=basePath%>js/bootstrap-datetimepicker.zh-CN.js'></script>
<!-- 全选 base.js -->
<script type="text/javascript" src="<%=basePath%>js/custom/base.js"></script>

<script type="text/javascript">
    //初始化时间
    $(".form_datetime").datetimepicker({
        format:'yyyy-mm-dd hh:ii:ss',
        todayHighlight: true,
        language:'zh-CN',
        autoclose: true
    });


    /* 查看 */
    function doView(id){
        $.ajax({
            url:'<%=basePath%>admin/getNotice',
            type:'GET',
            data:{id:id},
            dataType:'json',
            success:function(json){
                if(json){
                    $('#myviewform').find("input[name='id']").val(json.id);
                    $('#myviewform').find("textarea[name='context']").val(json.context);
                    $('#myviewform').find("input[name='createat']").val(json.create_at);
                    /!*$('#myviewform').find("input[name='createat']").val(json.orderDate);*!/
                    if(json.status==0){$('#myviewform').find("input[name='status']").val('未读');}
                    if(json.status==1){$('#myviewform').find("input[name='status']").val('已读');}

                    $('#viewModal').modal('toggle');
                }
            },
            error:function(){
                alert('请求超时或系统出错!');
                $('#viewModal').modal('hide');
            }
        });
    }

    /!* 删除 *!/
    function doDelete(id){
        $.ajax({
            url:'<%=basePath%>admin/deleteNotice',
            type:'POST',
            data:{id:id},
            dataType:'json',
            success:function(json){
                if(json) {
                    location.reload();
                }
            },
            error:function(){
                alert('请求超时或系统出错!');
                $('#viewModal').modal('hide');
            }
        });
    }


    //根据值 动态选中
    $("#myselected option[value='${searchnotice.status}']").attr("selected","selected");


</script>

</html>
